package com.cqc.mall.ware.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqc.mall.api.CommonResult;
import com.cqc.mall.ware.entity.InfoEntity;
import com.cqc.mall.ware.entity.WmsInfoEntity;
import com.cqc.mall.ware.feign.ProductFeignApi;
import com.cqc.mall.ware.service.WmsInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/test")
@RestController
@Api(tags = "仓库测试")
public class TestController {

    @Autowired
    private WmsInfoService wmsInfoService;

    @Autowired
    private ProductFeignApi productFeignApi;

    @GetMapping("/save")
    public CommonResult save() {
        WmsInfoEntity info = new WmsInfoEntity();
        info.setName("手机");
        info.setCount(2);
        return CommonResult.success(wmsInfoService.save(info));
    }


    @GetMapping("/getall")
    public CommonResult<IPage<WmsInfoEntity>> getAll() {
        Page<WmsInfoEntity> page = new Page<>();
        page.setCurrent(1);
        page.setSize(10);
        IPage<WmsInfoEntity> ipage = wmsInfoService.page(page, new QueryWrapper<WmsInfoEntity>());
        return CommonResult.success(ipage);
    }

    @GetMapping("/product")
    public CommonResult<InfoEntity> product() {
        CommonResult<InfoEntity> result = productFeignApi.getById();
        return result;
    }

}
